<?php
declare (strict_types = 1);
namespace app\user\service\user;

use app\common\service\BaseService;
use think\facade\Request;
use app\user\logic\user\Cart as CartLogic;

/**
 * 用户购物车接口类
 */
class Cart extends BaseService
{

    // 购物车数量
    public function getNum()
    {
        $data = app(CartLogic::class)->getNum();

        return $this->parseToData($data, 1, '获取成功');
    }

    // 购物车 - 页面
    public function cartFetch()
    {
        $data  = app(CartLogic::class)->cartFetch();
        
        return $this->parseToData($data, 1, '获取成功');
    }

    // 添加到购物车
    public function cartAdd()
    {
        $param = Request::post();
        $data  = app(CartLogic::class)->cartAdd($param);
        
        return $this->parseToData($data, 1, '添加成功');
    }

    // 移除购物车商品
    public function cartDelete()
    {
        $param = Request::put();
        $data  = app(CartLogic::class)->cartDelete($param);
        
        return $this->parseToData($data, 1, '移除成功');
    }
}
